package com.cssw.fyzb.busi.util;


/**
 * 腾讯加密解密工具
 *
 * @author Feng Chen
 */
public abstract class TxDes {

    private TxDes() {
        // Prevent Instantiation
    }

    /**
     * 加密(3Des + Base64)
     *
     * @param key       密钥
     * @param plainText 明文
     * @return 密文
     * @throws Exception
     */
    public static String encrypt(String key, String plainText) throws Exception {
        byte[] bytes = TripleDesUtil.encrypt(key, plainText);
        return Base64.encodeBytes(bytes);
    }

    /**
     * 解密(Base64 + 3Des)
     *
     * @param key        密钥
     * @param cipherText 密文
     * @return 明文
     * @throws Exception
     */
    public static String decrypt(String key, String cipherText) throws Exception {
        byte[] bytes = Base64.decode(cipherText.getBytes());
        return TripleDesUtil.decrypt(key, bytes);
    }

    public static void main(String[] args) throws Exception {
        String key = "xykj@2020";

//        String str = encrypt(key, "xingkong");
//        System.out.println(str);

        String str = "6Qf0/927CNNmqAIR0XU4VSdLFlmc+UVEJKotUrcZWKwsIgS2gj5ouXrwlLBZasYL2DK3oP9uRoZWU++aUODgg3HTTi13TvjOz+Cw4w7YHI4nlJ6vKqY1L7M0Jwm+nl8UM12x8B/f4k9ElqGraMsQ8VeoahVWKm0mBWXbVCK5ua/OEJSJ7rhKsdo78tKm3psG4m/y3fpoUwsMsMCGZi5APjyHz0TPrnpm4UDObPF9/7oHkw4MBxTVfzH9sBSKfwb6kxQCAusjWrlszmgF+pC8U2NoacNNMwBxmlY9/7t2YiIBeW1uohskzcA2hrpp90G2V0E82NFHYlB4hSa0Cf0fYk2iTPRzzw3WkSX9n8gMD3H/nZWSued+6HOkmC3t1IxLCsfirFPE50Wy4VEFzfcYJmx3pe0Yuu4sk5Zl/kZkJRVEEXK96qNDwHq40C4mcREqxShEf7KojVlZ8GUrBWjV4+geqmRm7FY/gPq7eOUUmu9GSrYryDgbdAisLqlS+AXHCJpwph+4RAtirPguCj4u9d4EMtq+5/PMc6UN2590oPQWXMfEyv2udPhbFEkkiJlDqIjw/GVp2mU=";

        String des = decrypt(key, str);
        System.out.println(des);

    }


}
